package jn.chen.utils;

import javax.swing.*;
import java.awt.*;
import java.util.Random;

/**
 * @className: dog
 * @author: chenLin
 * @version: 1.0.0
 * @description:
 * @date: 2022/10/10 18:28
 */
public class Dog extends JFrame {

    public Dog(int x, int y, int num) {
        setTitle("行不行啊细狗!");
        setBounds(x, y, 350, 150);
        getContentPane().setLayout(null);
        JPanel jPanel = new JPanel();
        jPanel.setBounds(0, 0, 350, 200);
        Color color[] =
                {
                        Color.GREEN, Color.BLUE, Color.CYAN, Color.MAGENTA, Color.RED, Color.YELLOW, Color.PINK, Color.WHITE, Color.ORANGE
                };
        jPanel.setBackground(color[num]);
        getContentPane().add(jPanel);
        JLabel jLabel = new JLabel("你行不行啊, 细狗~");
        jLabel.setFont(new Font("宋体", Font.BOLD, 26));
        jPanel.add(jLabel);
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        for (int i = 0; i < 200; i++) {
            Random random = new Random();
            int x = random.nextInt(1300) + 100;
            int y = random.nextInt(600) + 100;
            int num = random.nextInt(8);
            try {
                new Dog(x, y, num);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }
}
